<template>

  <el-table :data="tableData">
    <el-table-column align="center" label="项目名" prop="itemName"/>
    <el-table-column align="center" label="规格" prop="format"/>
    <el-table-column align="center" label="数量" prop="amount"/>
    <el-table-column align="center" label="单价" prop="price"/>
    <el-table-column align="center" label="总金额" prop="totalPrice"/>
    <el-table-column align="center" label="类型" prop="type" :formatter="typeFormat"/>
    <el-table-column align="center" label="状态" prop="status" :formatter="statusFormat"/>
  </el-table>

</template>

<script>
  import {list_patient_bill} from "@/api/dms/patient_bill";

  export default {
    // 接收父组件传参
    props: ["registrationId"],
    data() {
      return {
        //患者账单数据
        tableData: [],
        // 状态字典
        statusOptions: [],
        // 类型字典
        typeOptions: []
      }
    },
    created() {
      this.getList();
      this.getDicts("non_drug_item_status").then(response => {
        this.statusOptions = response.data;
      });
      this.getDicts("no_drug_type").then(response => {
        this.typeOptions = response.data;
      });
    },
    methods: {
      /** 查询患者费用列表 */
      getList() {
        this.loading = true;
        list_patient_bill(this.registrationId).then(response => {
          this.tableData = response.data;
        });
      },
      // 状态字典翻译
      statusFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.status);
      },
      // 类型字典翻译
      typeFormat(row, column) {
        if (isNaN(row.type)) {
          return row.type;
        } else {
          return this.selectDictLabel(this.typeOptions, row.type);
        }
      },
    }
  }
</script>
